﻿using Infrastructure.Attribute;
using Microsoft.Extensions.DependencyInjection;
using Quartz;
using SqlSugar.IOC;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZR.Tasks.TaskScheduler
{
    [AppService(ServiceType = typeof(Job_Mytask), ServiceLifetime = LifeTime.Scoped)]
    public class Job_Mytask : JobBase, IJob
    {
        private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

        public async Task Execute(IJobExecutionContext context)
        {
            await ExecuteJob(context, async () => await Run());
        }

        public async Task Run()
        {
            await Task.Delay(1);
            //TODO 业务逻辑
            logger.Info("定时任务测试===============================================================================================");
            string sql = "INSERT INTO sys_notice (notice_title, notice_type) VALUES ('tast test', 1)";
            var result = DbScoped.SugarScope.Ado.ExecuteCommandWithGo(sql);
        }
    }
}
